﻿using System.Windows.Controls;
using System.Collections.Generic;
using System.Diagnostics;

namespace Amercom.Silverlight.Lib
{
     class DebugLogger
    {
        private static List<TextBlock> lstTextBox;
        private static bool outputToLog = false;
        public static bool enabled = false;
        public static void addOutputTextBlock(TextBlock newBlock)
        {
            if (lstTextBox == null)
            {
                lstTextBox = new List<TextBlock>();
            }        
            lstTextBox.Add(newBlock);            
        }

        public static void debugWrite(string text)
        {
            if (enabled!=false)
            {
                if (outputToLog)
                {
                    Debug.WriteLine(text);
                }
                if (lstTextBox != null)
                {
                    foreach (TextBlock txtOut in lstTextBox)
                    {
                        txtOut.Text = text + "\n" + txtOut.Text;
                    }
                }
            }
        }

        public static void enableOutputLog(bool enable)
        {
            outputToLog = enable;
        }

    }
}
